<%--
  Created by IntelliJ IDEA.
  User: Dink
  Date: 2022/1/18
  Time: 16:51
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<html>
<head>
    <title>手游基础信息添加页面</title>
</head>
<body>
<%@ include file="comment/header.jsp"%>
<div style="position: relative;left: 230px;top:-10px;width: 1270px">
        <div class="row">
            <div class="col-md-12 col-sm-12 col-xs-12">
                <div class="x_panel">
                    <div class="x_content">
                        <form action="${pageContext.request.contextPath}/app_info/add" onsubmit="return regs();" class="form-horizontal form-label-left"  enctype="multipart/form-data" method="post" >
                            <p style="font-size: 20px"><span >新增APP基础信息
                                <span class="glyphicon glyphicon-user" aria-hidden="true"></span>
                            </span>
                            </p>
                            <div class="clearfix"></div>
                            <div class="item form-group">
                                <label class="control-label col-md-3 col-sm-3 col-xs-12" for="name">软件名称 <span class="required">*</span>
                                </label>
                                <div class="col-md-6 col-sm-6 col-xs-12">
                                    <input id="name" class="form-control col-md-7 col-xs-12" data-validate-length-range="6" data-validate-words="2" name="softwareName" placeholder="请输入软件名称" required="required" type="text">
                                </div>
                            </div>
                            <div class="item form-group">
                                <label class="control-label col-md-3 col-sm-3 col-xs-12">AKP名称 <span class="required">*</span>
                                </label>
                                <div class="col-md-6 col-sm-6 col-xs-12">
                                    <input  onblur="checkAPKName()" required="required" type="text" name="APKName" placeholder="请输入APK名称"  class="form-control col-md-7 col-xs-12">
                                </div>
                                <span style="color: red" id="APKName"></span>
                            </div>
                            <div class="item form-group">
                                <label class="control-label col-md-3 col-sm-3 col-xs-12">支持ROM <span class="required">*</span>
                                </label>
                                <div class="col-md-6 col-sm-6 col-xs-12">
                                    <input class="form-control col-md-7 col-xs-12" data-validate-length-range="6" data-validate-words="2" name="supportROM" placeholder="请输入支持的ROM" required="required" type="text">
                                </div>
                            </div>
                            <div class="item form-group">
                                <label class="control-label col-md-3 col-sm-3 col-xs-12">界面语言 <span class="required">*</span>
                                </label>
                                <div class="col-md-6 col-sm-6 col-xs-12">
                                    <input  name="interfaceLanguage" placeholder="请输入软件支持的界面语言" required="required" class="form-control col-md-7 col-xs-12">
                                </div>
                            </div>
                            <div class="item form-group">
                                <label class="control-label col-md-3 col-sm-3 col-xs-12" for="website">软件大小 <span class="required">*</span>
                                </label>
                                <div class="col-md-6 col-sm-6 col-xs-12">
                                    <input type="number" id="website" name="softwareSize" required="required" placeholder="请输入软件大小，单位为Mb" class="form-control col-md-7 col-xs-12">
                                </div>
                            </div>
                            <div class="item form-group">
                                <label class="control-label col-md-3 col-sm-3 col-xs-12" >下载次数 <span class="required">*</span>
                                </label>
                                <div class="col-md-6 col-sm-6 col-xs-12">
                                    <input type="number"  name="downloads" required="required" placeholder="请输入下次数" class="form-control col-md-7 col-xs-12">
                                </div>
                            </div>
                            <div class="item form-group">
                                <label class="control-label col-md-3">所属平台<span class="required">*</span></label>
                                <div class="col-md-6 col-sm-6 col-xs-12">
                                    <select name="flatformId" class="form-control col-md-7 col-xs-12">
                                        <option value="0">--请选择--</option>
                                        <c:forEach items="${flatform}" var="flatform">
                                            <option value="${flatform.valueId}">${flatform.valueName}</option>
                                        </c:forEach>
                                    </select>
                                </div>
                            </div>
                            <div class="item form-group">
                                <label class="control-label col-md-3">一级分类<span class="required">*</span></label>
                                <div class="col-md-6 col-sm-6 col-xs-12">
                                    <select onclick="classifyOne(this.value)" name="categoryLevel1" class="form-control col-md-7 col-xs-12">
                                    </select>
                                </div>
                            </div>
                            <div class="item form-group">
                                <label class="control-label col-md-3">二级分类<span class="required">*</span></label>
                                <div class="col-md-6 col-sm-6 col-xs-12">
                                    <select onchange="classifyTwo(this.value)" name="categoryLevel2" class="form-control col-md-7 col-xs-12">
                                    </select>
                                </div>
                            </div>
                            <div class="item form-group">
                                <label class="control-label col-md-3">三级分类<span class="required">*</span></label>
                                <div class="col-md-6 col-sm-6 col-xs-12">
                                    <select name="categoryLevel3" class="form-control col-md-7 col-xs-12">
                                    </select>
                                </div>
                            </div>
                            <div class="item form-group">
                                <label  class="control-label col-md-3 col-sm-3 col-xs-12">APP状态<span class="required">*</span></label>
                                <div class="col-md-6 col-sm-6 col-xs-12">
                                    <input  type="hidden" name="status" value="1">
                                    <span class="required">待审核</span>
                                </div>
                            </div>
                            <div class="item form-group">
                                <label class="control-label col-md-3 col-sm-3 col-xs-12" for="textarea">应用简介 <span class="required">*</span>
                                </label>
                                <div class="col-md-6 col-sm-6 col-xs-12">
                                    <textarea id="textarea"   required="required" placeholder="请输入本软件相关信息，本信息作为软件的详细信息进行软件的介绍" name="appInfo" class="form-control col-md-7 col-xs-12"></textarea>
                                </div>
                            </div>
                            <div class="item form-group">
                                <label class="control-label col-md-3 col-sm-3 col-xs-12" for="telephone">LOGO图片 <span class="required">*</span>
                                </label>
                                <div class="col-md-6 col-sm-6 col-xs-12">
                                    <input type="file" id="telephone" name="file" required="required" data-validate-length-range="8,20" class="form-control col-md-7 col-xs-12">
                                </div>
                                <span style="color: red">${fileUploadErro}</span>
                            </div>
                            <div class="ln_solid"></div>
                            <div class="form-group">
                                <div class="col-md-6 col-md-offset-3">
                                    <button type="submit" class="btn btn-primary">保存</button>
                                    <a href="${pageContext.request.contextPath}/app_info/list"><button id="send" type="button" class="btn btn-success">返回</button></a>
                                </div>
                            </div>
                        </form>
                    </div>
                </div>
            </div>
        </div>
</div>
<%@ include file="comment/foot.jsp"%>
</body>
<script type="text/javascript" src="../../statics/js/jquery.js"></script>
<script type="text/javascript">
    function regs(){
        if($("[name=softwareName]").val()==''||$("[name=APKName]").val()==''||$("[name=supportROM]").val()==''||
            $("[name=interfaceLanguage]").val()==''||$("[name=softwareSize]").val()==''||$("[name=downloads]").val()==''||
            $("[name=flatformId]").val()==''||$("[name=categoryLevel1]").val()==''||$("[name=categoryLevel2]").val()==''||
            $("[name=categoryLevel3]").val()==''||$("[name=appInfo]").val()==''||$("[name=logoLocPath]").val()==''
        ){
            alert("请填写完整所有项！");
            return false;
        }
        return  true;
    }

    function checkAPKName(){
        $.getJSON('${pageContext.request.contextPath}/app_info/checkAPKName?AKPName='+$("[name=APKName]").val(),function (data) {
            if(data.flag){
            $("#APKName").html("此APKName已有,请重新输入！");
            }else {
                $("#APKName").html("");
            }
        });
    }

    $(function () {
        $("[name=categoryLevel1]").html("");
        $.getJSON('${pageContext.request.contextPath}/app_info/categroyleve1?id=1',function (data) {
            var options='';
            options += '<option value="0">--请选择--</option>';
            for (var i=0;i<data.length;i++){
                options+='<option value="'+data[i].id+'"\n' +
                    '>'+data[i].categoryName+'</option>';
            }
            $("[name=categoryLevel1]").append(options);
        });
    })
    function classifyOne(categoryLeve) {
        $("[name=categoryLevel2]").html("");
        var options='<option value="0">--请选择--</option>';
        $.getJSON('${pageContext.request.contextPath}/app_info/categroyleve1?id='+categoryLeve,function (data) {
            for (var i=0;i<data.length;i++){
                options+='<option value="'+data[i].id+'"\n' +
                    '>'+data[i].categoryName+'</option>';
            }
            $("[name=categoryLevel2]").append(options);
        });
    }
    function classifyTwo(categoryLeve) {
        $("[name=categoryLevel3]").html("");
        var options='<option value="0">--请选择--</option>';
        $.getJSON('${pageContext.request.contextPath}/app_info/categroyleve1?id='+categoryLeve,function (data) {
            for (var i=0;i<data.length;i++){
                options+='<option value="'+data[i].id+'"\n' +
                    '>'+data[i].categoryName+'</option>';
            }
            $("[name=categoryLevel3]").append(options);
        });
    }
    /*$(function () {
        var CategoryLevel1=$("[name=getCategoryLevel1]").val();
        var CategoryLevel2=$("[name=getCategoryLevel2]").val();
        if(CategoryLevel1!=""&&CategoryLevel2!=""&&CategoryLevel2!=0&&CategoryLevel1!=0){
            var options2='<option value="0">--请选择--</option>';
            var options3='<option value="0">--请选择--</option>';
            var CategoryLevel1=$("[name=getCategoryLevel1]").val();
            var CategoryLevel2=$("[name=getCategoryLevel2]").val();
            var CategoryLevel3=$("[name=getCategoryLevel3]").val();
            $.getJSON('${pageContext.request.contextPath}/app_info/categroyleve23?id2='+CategoryLevel1+'&id3='+CategoryLevel2,function (data) {
                for (var i=0;i<data.list2.length;i++){
                    if(data.list2[i].id==CategoryLevel2){
                        options2+='<option value="'+data.list2[i].id+'" selected="selected"\n' +
                            '>'+data.list2[i].categoryName+'</option>';
                    }else {
                        options2+='<option value="'+data.list2[i].id+'"\n' +
                            '>'+data.list2[i].categoryName+'</option>';
                    }
                }
                for (var s=0;s<data.list3.length;s++){
                    if(data.list3[s].id==CategoryLevel3){
                        options3+='<option value="'+data.list3[s].id+'"selected="selected"\n' +
                            '>'+data.list3[s].categoryName+'</option>';
                    }else {
                        options3+='<option value="'+data.list3[s].id+'"\n' +
                            '>'+data.list3[s].categoryName+'</option>';
                    }
                }
                $("[name=categoryLevel2]").append(options2);
                $("[name=categoryLevel3]").append(options3);
            });
        }
    });*/
</script>
</html>
